﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddNewUser.aspx.cs" Inherits="TheatreStaff_AddNewUser" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
   public void function1(object source, ServerValidateEventArgs args)
    {

        string username = UsernameTextbox.Text;
        Label2.Text = "1";

        string connectionString;
        connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(connectionString);
        SqlCommand cmd1 = new SqlCommand("SELECT TheatreStaffUserName,TheatreId from TheatreStaff WHERE TheatreStaffUserName=@TheatreStaffUserName", con);
        string ParamString = lblId.Text;
        Boolean Showing;

        cmd1.Parameters.AddWithValue("TheatreStaffUserName", username);
        using (con)
        {
            con.Open();
            SqlDataReader reader = cmd1.ExecuteReader();
            if (reader.HasRows)
            {
                Label2.Text = "1";
                args.IsValid = false;
                Showing = false;
                

            }
            else
            {
                Label2.Text = "2";
                Showing = true;
                args.IsValid = true;
            }
        }
    }
    
    
    public void Clear(object sender, EventArgs args)
    {
        Label1.Text = string.Empty;
 
        
    }
    public void CreateUser_OnClick(object sender, EventArgs args)
    {

        string username = UsernameTextbox.Text;
        Label2.Text = "1";

        string connectionString1;
        connectionString1 = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con1 = new SqlConnection(connectionString1);
        SqlCommand cmd1 = new SqlCommand("SELECT TheatreStaffUserName,TheatreId from TheatreStaff WHERE TheatreStaffUserName=@TheatreStaffUserName", con1);
        string ParamString = lblId.Text;
        Boolean Showing;

        cmd1.Parameters.AddWithValue("TheatreStaffUserName", username);
        using (con1)
        {
            con1.Open();
            SqlDataReader reader = cmd1.ExecuteReader();
            if (reader.HasRows)
            {
                Label2.Text = "1";
   
                Showing = false;


            }
            else
            {
                Label2.Text = "2";
                Showing = true;
           
            }
        }


        if (Showing == true)
        {

            MembershipCreateStatus result;

            try
            {
                // Create new user.

                if (Membership.RequiresQuestionAndAnswer)
                {
                    MembershipUser newUser = Membership.CreateUser(
                      UsernameTextbox.Text,
                      PasswordTextbox.Text,
                      EmailTextbox.Text,
                      PasswordQuestionTextbox.Text,
                      PasswordAnswerTextbox.Text,
                      true,
                      out result);


                    if (Roles.RoleExists("Theatre"))
                    {
                        if (!Roles.IsUserInRole(UsernameTextbox.Text,"Theatre"))
                        {
                           
                            Roles.AddUserToRole(UsernameTextbox.Text, "Theatre");
                        }

                
                    }
                    string connectionString;
                    connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

                    SqlConnection con = new SqlConnection(connectionString);
                    SqlCommand cmd = new SqlCommand("INSERT TheatreStaff(TheatreStaffUserName,TheatreStaffAcessLevel,TheatreId) values (@UName,@ALevel,@Id)", con);
                    cmd.Parameters.AddWithValue("@UName", UsernameTextbox.Text);
                    cmd.Parameters.AddWithValue("@ALevel", "Theatre");
                    cmd.Parameters.AddWithValue("@Id", lblId.Text);


                    using (con)
                    {
                        con.Open();
                        Int32 rowCount = cmd.ExecuteNonQuery();

                        if (rowCount > 0)
                        {
                  
                            Label1.Text = "The New user "+UsernameTextbox.Text+ " has been added sucessfully to the theatre "+  Label5.Text ;
                            
                             UsernameTextbox.Text="";
                      PasswordTextbox.Text="";
                      EmailTextbox.Text="";
                      PasswordQuestionTextbox.Text="";
                      PasswordAnswerTextbox.Text = "";
                            
                        }

                    }
                }
                else
                {
                    MembershipUser newUser = Membership.CreateUser(
                      UsernameTextbox.Text,
                      PasswordTextbox.Text,
                      EmailTextbox.Text);
                    if (!Roles.IsUserInRole(UsernameTextbox.Text, "Theatre"))
                    {

                        Roles.AddUserToRole(UsernameTextbox.Text, "Theatre");
                    }

            
                    string connectionString;
                    connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

                    SqlConnection con = new SqlConnection(connectionString);
                    SqlCommand cmd = new SqlCommand("INSERT TheatreStaff(TheatreStaffUserName,TheatreStaffAcessLevel,TheatreId) values (@UName,@ALevel,@Id)", con);
                    cmd.Parameters.AddWithValue("@UName", UsernameTextbox.Text);
                    cmd.Parameters.AddWithValue("@ALevel", "Theatre");
                    cmd.Parameters.AddWithValue("@Id", lblId.Text);


                    using (con)
                    {
                        con.Open();
                        Int32 rowCount = cmd.ExecuteNonQuery();

                        //if (rowCount > 0)
                        //{
                        //    lresult.Text = "The New user has been added sucessfully to the theatre!";
                        //}

                    }
                }

                //Response.Redirect("login.aspx");
            }
            catch (MembershipCreateUserException e)
            {
                Msg.Text = GetErrorMessage(e.StatusCode);
            }
            catch (HttpException e)
            {
                Msg.Text = e.Message;
            }

        }
    }

    public string GetErrorMessage(MembershipCreateStatus status)
    {
        switch (status)
        {
            case MembershipCreateStatus.DuplicateUserName:
                return "Username already exists. Please enter a different user name.";

            case MembershipCreateStatus.DuplicateEmail:
                return "A username for that e-mail address already exists. Please enter a different e-mail address.";

            case MembershipCreateStatus.InvalidPassword:
                return "The password provided is invalid. Please enter a valid password value.";

            case MembershipCreateStatus.InvalidEmail:
                return "The e-mail address provided is invalid. Please check the value and try again.";

            case MembershipCreateStatus.InvalidAnswer:
                return "The password retrieval answer provided is invalid. Please check the value and try again.";

            case MembershipCreateStatus.InvalidQuestion:
                return "The password retrieval question provided is invalid. Please check the value and try again.";

            case MembershipCreateStatus.InvalidUserName:
                return "The user name provided is invalid. Please check the value and try again.";

            case MembershipCreateStatus.ProviderError:
                return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

            case MembershipCreateStatus.UserRejected:
                return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

            default:
                return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
        }
    }

    //protected void AddUser(object sender, EventArgs e)
    //{
        
    //    //UserName1 = 
    //    TextBox UserName1 = (TextBox)CreateUserWizard1.FindControl("UserName");
    //    string UN = UserName1.Text;
        
    //    //MembershipCreateStatus status;

    //    //Membership.CreateUser(txtUName.Text, txtPword.Text,txtEmail.Text );


    //    if (Roles.RoleExists("Theatre"))
    //    {
    //        if (!Roles.IsUserInRole("Theatre"))
    //        {
    //            Roles.AddUserToRole(UN , "Theatre");
    //        }
    //    }

    //    string connectionString;
    //    connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

    //    SqlConnection con = new SqlConnection(connectionString);
    //    SqlCommand cmd = new SqlCommand("INSERT TheatreStaff(TheatreStaffUserName,TheatreStaffAcessLevel,TheatreId) values (@UName,@ALevel,@Id)", con);
    //    cmd.Parameters.AddWithValue("@UName", UN);
    //    cmd.Parameters.AddWithValue("@ALevel", "Theatre");
    //    cmd.Parameters.AddWithValue("@Id", lblId.Text);


    //    using (con)
    //    {
    //        con.Open();
    //        Int32 rowCount = cmd.ExecuteNonQuery();

    //        if (rowCount > 0)
    //        {
    //            lresult.Text = "The New user has been added sucessfully to the theatre!";
    //        }
            
    //    }
    //}
    //protected void  btnCreate_Click(object sender, EventArgs e)
    //{
    //    string userName  = txtUserId.Text;
    //    string password  = txtPassword.Text;
    //    string email =txtEmail.Text;
    //    string passwordQuestion = ddlPasswordQuestion.SelectedValue;
    //    string passwordAnswer = txtPasswordAnswer.Text;
        
    //    //MembershipCreateStatus result;
    //    MembershipUser newUser = Membership.CreateUser(userName, password);
    //    //Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, true, result);


    //    //lblResults.Visible = true;
    //     if (Roles.RoleExists("Theatre"))
    //     {
    //         if (!Roles.IsUserInRole("Theatre"))
    //         {
    //             Roles.AddUserToRole(userName , "Theatre");
    //         }
    //     }

    //    string connectionString;
    //    connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

    //    SqlConnection con = new SqlConnection(connectionString);
    //    SqlCommand cmd = new SqlCommand("INSERT TheatreStaff(TheatreStaffUserName,TheatreStaffAcessLevel,TheatreId) values (@UName,@ALevel,@Id)", con);
    //    cmd.Parameters.AddWithValue("@UName", UN);
    //    cmd.Parameters.AddWithValue("@ALevel", "Theatre");
    //    cmd.Parameters.AddWithValue("@Id", lblId.Text);


    //    using (con)
    //    {
    //        con.Open();
    //        Int32 rowCount = cmd.ExecuteNonQuery();

    //        if (rowCount > 0)
    //        {
    //            lresult.Text = "The New user has been added sucessfully to the theatre!";
    //        }
            
    //    }
        //switch (result)
        //{
        //    case MembershipCreateStatus.Success:
        //            txtUserId.Text = "";
        //            txtPassword.Text = "";
        //            txtEmail.Text = "";
        //            ddlPasswordQuestion.SelectedIndex = -1;
        //            txtPasswordAnswer.Text = "";
        //            lblResults.Text = "User successfully created!" ;
        //    case MembershipCreateStatus.InvalidUserName:
        //            lblResults.Text = "The username format was invalid.  Please enter a different username.";
        //    case MembershipCreateStatus.InvalidPassword:
        //            lblResults.Text = "The password was invalid:  A password cannot be an empty string and must also meet the pasword strength requirements of the configured provider.  Please enter a new password.";
        //    case MembershipCreateStatus.InvalidEmail:
        //            lblResults.Text = "The email format was invalid.  Please enter a different username.";
        //    case MembershipCreateStatus.InvalidQuestion:
        //            lblResults.Text = "The password question format was invalid.  Please enter a different question.";
        //    case MembershipCreateStatus.InvalidAnswer:
        //            lblResults.Text = "The password answer format was invalid.  Please enter a different answer.";
        //    case MembershipCreateStatus.DuplicateUserName:
        //            lblResults.Text = "The username is already in use.  Please enter a new username.";
        //    case MembershipCreateStatus.DuplicateEmail:
        //            lblResults.Text = "The email address is already in use.  Please enter a different email address.";
        //    default:
        //            lblResults.Text = "An error occurred while creating the user.";
                    
                
                
        
        //}
    //}

   
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<%--This below code from the website:http://ramanisandeep.wordpress.com/2008/11/07/hide-an-aspnet-label-control-after-a-few-seconds/--%>
<script type="text/javascript">
    self.setInterval("changeValue1()", 5000);

    function changeValue1() {
        document.getElementById("Label1").innerText = "";

    }
 
</script>
<script type="text/javascript">
        
        function displayCalendar()
        {
            var datePicker = document.getElementById('datePicker');
            datePicker.style.display = 'block';
        }
        function showInsert() {
            var divInsert = document.getElementById('divInsert');
            divInsert.style.display = 'block';
        }
</script>

<script type="text/javascript">
function showInsert() {
    var divInsert = document.getElementById('divInsert');
    divInsert.style.display = 'block';
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:800px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    
  
}

.content
{
    width:950px;
    margin:auto;
        height: 197px;
    }

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}

.ticket:hover
{
 color: black; 
  text-decoration:none;


}
    .style1
    {
        width: 509px;
    }
    
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:150px;  
}
.view5
{
 padding-left:350px;  
}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}
.footer
{

  margin-bottom:100px;
}
.center
{
    padding-left:410px;
}
.center1
{
    padding-left:320px;
}
.center2
{
    padding-left:0px;
}
.cinema
{
    padding-left:590px;
}
  #footer {
        position: fixed;
        width: 100%;
        height: 100px;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
      }
      .cinema
{
    padding-left:590px;
}
     .menu
{
 padding-left:180px;  

}
legend
{
  color:White;   

}
</style>
    <title>Add new user</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
 <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>


 <br /> <br />
 <table class="center1" >
        <tr>
            <td>
               <asp:Label ID="Label3" runat="server" CssClass="menu"  Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label5" runat="server"  ForeColor="Yellow"></asp:Label>
                 &nbsp;&nbsp
            </td>
       <%-- </tr>
 </table> --%>
    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
<%--&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp --%>
  <%--<table align="center" >
        <tr>--%>
            <td>
                <asp:Label ID="Label04" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
                &nbsp;&nbsp;
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>
    <hr />
  <asp:Label ID="Label8" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;  
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp;  
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;  
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp;  
   <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp;
           <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp; 

  <hr />
   <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>      
   <%-- <fieldset >
        <legend >Add New Theatre Staff</legend>
        <table >
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="User Name:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtUName" runat="server"></asp:TextBox>
                </td>
                <td colspan="2">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" 
                     ControlToValidate="txtUName"  runat="server" ErrorMessage="(Required)"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label2" runat="server" Text="Password:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPword"  runat="server"></asp:TextBox>
                </td>
                <td colspan="2">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" 
                     ControlToValidate="txtPword"  runat="server" ErrorMessage="(Required)"></asp:RequiredFieldValidator>
                </td>
            </tr>
             <tr>
                <td>
                    <asp:Label ID="Label6" runat="server" Text="Email:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" 
                     ControlToValidate="txtEmail"  runat="server" ErrorMessage="(Required)"></asp:RequiredFieldValidator>
                </td>
                <td>
                    <asp:RegularExpressionValidator ID="regEmail"
                     runat="server" ErrorMessage="(Invalid Email Address)" 
                     ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnAdd" runat="server" Text="Add User" OnClick="AddUser" />
                </td>
            </tr>
             <tr>
                <td>
                   <asp:Label ID="lresult" runat="server" Text="" ></asp:Label>
                </td>
            </tr>
        </table>
    </fieldset>--%>
   <%-- <asp:CreateUserWizard
        id="CreateUserWizard1"  LoginCreatedUser="false"
        Runat="server">
        <WizardSteps>
        <asp:CreateUserWizardStep>
        <ContentTemplate>
        <h1>Register</h1>
        <table >
            <tr>
                <td>
            <asp:Label
                id="ErrorMessage"
                ForeColor="Red"
                Runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label
                    id="lblUserName"
                    Text="User Name:"
                    AssociatedControlID="UserName"
                    Runat="server" />
                </td>
                <td>
                     <asp:TextBox
                    id="UserName"
                    Runat="server" />
                </td>
       
            </tr>
            <tr>
                <td>
                        <asp:Label
                    id="lblPassword"
                    Text="Password:"
                    AssociatedControlID="Password"
                    Runat="server" />
                </td>
                <td>
                    <asp:TextBox
                    id="Password"
                    TextMode="Password"
                    Runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label
                    id="lblEmail"
                    Text="Email:"
                    AssociatedControlID="Email"
                    Runat="server" />
                </td>
                <td>
                     <asp:TextBox
                    id="Email"
                    Runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                     <asp:Label
            id="lblQuestion"
            Text="Security Question:"
            AssociatedControlID="Question"
            Runat="server" />
                </td>
                <td>
                    <asp:DropDownList
            id="Question"
            Runat="server">
            <asp:ListItem 
                Text="Enter the name of your pet"
                Value="Pet Name" />
            <asp:ListItem 
                Text="Enter your favorite color"
                Value="Favorite Color" />
        </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label
            id="lblAnswer"
            Text="Security Answer:"
            AssociatedControlID="Answer"
            Runat="server" />
                </td>
                <td>
                    <asp:TextBox
            id="Answer"
            Runat="server" />
                </td>
            </tr>
        </table>
        </ContentTemplate>
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep>
        <ContentTemplate>
            Your account was successfully created.
        </ContentTemplate>    
        </asp:CompleteWizardStep>
        </WizardSteps>    
    </asp:CreateUserWizard>--%>
    <%--<asp:CreateUserWizard ID="CreateUserWizard1"  OnCreatedUser="AddUser"     LoginCreatedUser="false"   runat="server">
            <WizardSteps>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1"  runat="server">
             <ContentTemplate>
        <table align="left" width="400px">  
   
                       
<tr><td >     <asp:Label id="lblUserName" Text="User Name:" AssociatedControlID="UserName" Runat="server" /></td>

<td>   <asp:TextBox id="UserName" Runat="server" /></td></tr>

   <tr><td><asp:Label id="lblPassword" Text="Password:" AssociatedControlID="Password" Runat="server" /></td>

 <td>  <asp:TextBox id="Password" TextMode="Password" Runat="server" /></td></tr>
 <tr><td>
 <asp:Label id="lblEmail" Text="Email:" AssociatedControlID="Email" Runat="server" /></td>
<td>   <asp:TextBox id="Email" Runat="server" /></td></tr>

<tr><td> <asp:Label id="lblQuestion" Text="Security Question:"  AssociatedControlID="Question" Runat="server" /></td>
<td><asp:DropDownList id="Question" Runat="server">
      <asp:ListItem  Text="Enter the name of your pet" Value="Pet Name" />
<asp:ListItem  Text="Enter your favorite color" Value="Favorite Color" />
        </asp:DropDownList></td></tr> 

<tr><td> <asp:Label id="lblAnswer" Text="Security Answer:" AssociatedControlID="Answer" Runat="server" /></td>

    <td>    <asp:TextBox id="Answer"  Runat="server" /></td></tr>

          <tr><td>  </td></tr> 
    
    </table>  
             
                </ContentTemplate>

                     </asp:CreateUserWizardStep>  
               
                
            </WizardSteps>
        </asp:CreateUserWizard>
    <table >
        <tr>
            <td>
               <asp:Label ID="lresult" runat="server" Text="" ></asp:Label>
            </td>
        </tr>
    </table>
        <asp:TextBox ID="UserName1" Visible="false" runat="server"></asp:TextBox>
        <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>   
   <div id="footer"> --%>
 <%--<table id="tblLogin" cellspacing="1" cellpadding="1" style="border-right: black thin solid; border-top: black thin solid; border-left: black thin solid; border-bottom: black thin solid; width: 422px; height: 189px;">
          <tr>
              <td colspan="2" >
                  <div style="text-align: center">
                      <strong><span style="text-decoration: underline">Create New User</span></strong>
                  </div>
              </td>
          </tr>
          <tr>
              <td width="40%">User ID:</td>
              <td>
                  <asp:textbox id="txtUserId" runat="server" width="100%">username</asp:textbox>
              </td>
          </tr>
          <tr>
              <td>Password:</td>
              <td>
                  <asp:textbox id="txtPassword" runat="server" textmode="Password" width="100%"></asp:textbox>
              </td>
          </tr>
          <tr>
              <td>
                  Email:</td>
              <td>
                  <asp:textbox id="txtEmail" runat="server" width="100%">myemail@foo.org</asp:textbox>
              </td>
          </tr>
          <tr>
              <td>
                  Password Question:</td>
              <td>
                <asp:DropDownList ID="ddlPasswordQuestion" Runat="server" Width="100%">
                  <asp:ListItem>What is your mother's maiden name?</asp:ListItem>
                  <asp:ListItem>Where were you born?</asp:ListItem>
                  <asp:ListItem>What kind of car do you drive?</asp:ListItem>
                </asp:DropDownList>
              </td>
          </tr>
          <tr>
              <td>
                  Password Answer:</td>
              <td>
                  <asp:textbox id="txtPasswordAnswer" runat="server" width="100%"></asp:textbox>
              </td>
          </tr>                    
          <tr>
              <td style="TEXT-ALIGN: center" colspan="2">
                  <asp:button id="btnCreate" runat="server" text="Click to Create User" OnClick="btnCreate_Click" />
              </td>
          </tr>
        </table>
        <br />
        <br />
         <asp:label id="lblResults" runat="server" Visible=false>Results:</asp:label>&nbsp;<br />--%>
        <h3><asp:Label ID="Label7" runat="server" CssClass="view5" ForeColor="#66FF99" Text="Add New User Account"></asp:Label></h3>
         <asp:BulletedList CssClass="view2" ForeColor="white" runat="server"   >
            <asp:ListItem Text="Please Complete the following form to 
     add a new user to your theatre" />           
         </asp:BulletedList>
         <div class="view2">
             <asp:ScriptManager ID="ScriptManager1" runat="server" />
             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
             <ContentTemplate>
        <asp:Label ID="Label2" runat="server" Visible="false" ></asp:Label>
     <%--Please Complete the following form to create a new user for your theatre--%>           
 <fieldset>
 <legend >Add New User</legend>
    
     
  <asp:Label id="Msg" ForeColor="maroon" runat="server" /><br />
 <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Larger" 
            ForeColor="#FFFFCC"></asp:Label>
  <%--cellpadding="3"--%>
  <table  border="0">
    <tr>
      <td>Username:</td>
      <td><asp:Textbox  id="UsernameTextbox" OnTextChanged="Clear"  runat="server" /></td>
      <td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
                                      ControlToValidate="UserNameTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" />
    <asp:CustomValidator  ID="CustomValidator1"  ControlToValidate="UsernameTextbox"  OnServerValidate="function1"  runat="server" Text="This username already exist, please try another" ErrorMessage="CustomValidator" />                         
                                      
                                      
                                      
                                      </td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
      <td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
                                      ControlToValidate="PasswordTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /></td>
    </tr>
    <tr>
      <td>Confirm Password:</td>
      <td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
      <td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
                                      ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" />
          <asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
                                      ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
                                      Display="Static" ControlToCompare="PasswordTextBox"
                                      ErrorMessage="Confirm password must match password." />
      </td>
    </tr>
    <tr>
      <td>Email Address:</td>
      <td><asp:Textbox id="EmailTextbox" runat="server" /></td>
      <td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
                                      ControlToValidate="EmailTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /></td>
    </tr>


<% if (Membership.RequiresQuestionAndAnswer) { %>

    <tr>
      <td>Password Question:</td>
      <td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
      <td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
                                      ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /></td>
    </tr>
    <tr>
      <td>Password Answer:</td>
      <td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
      <td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
                                      ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
                                      Display="Static" ErrorMessage="Required" /></td>
    </tr>

<% } %>


    <tr>
      <td></td>
      <td><asp:Button id="CreateUserButton" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
    </tr>
    
  </table>
  
 
 </fieldset>
  </ContentTemplate>
             </asp:UpdatePanel>
       </div>
       <%-- <hr />--%>
 <br /><br />
 <table width="100" cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>
</div>
</form>
</body>
</html>
